<?php
require('../config.php');

		$user_id=$_REQUEST['user_id'];
		$gid=$_REQUEST['gid'];
		$sql="select m.*,s.thumb,s.q_end_time,s.q_uid,s.sid,s.qishu from `".$oto."_member_go_record` as m,`".$oto."_shoplist` as s where s.q_showtime='N' and s.id=m.shopid and m.id='{$gid}' order by m.time desc";
		$result=$db->query($sql);
		while($row=$result->fetch_assoc()){
			$ubuydetail[]=$row;//将取得的所有数据赋值给person_info数组
		}
		if(isset($ubuydetail))
		{
			for($i=0;$i<count($ubuydetail);$i++)
			{
				$xsd=explode('.',$ubuydetail[$i]['q_end_time']);
				if(count($xsd)>1) $xsd=$xsd[1];
				else $xsd=$xsd[0];
				$ubuydetail[$i]['jx_time']=date('Y-m-d H:i:s',$ubuydetail[$i]['q_end_time']).'.'.$xsd;
				$xsd=explode('.',$ubuydetail[$i]['time']);
				if(count($xsd)>1) $xsd=$xsd[1];
				else $xsd=$xsd[0];
				$ubuydetail[$i]['buy_time']=date('Y-m-d H:i:s',$ubuydetail[$i]['time']).'.'.$xsd;
				$ubuydetail[$i]['goucode_list']=explode(",",$ubuydetail[$i]['goucode']);
				$q_uid=$ubuydetail[$i]['q_uid'];
				$sql="select userName from ".$oto."_users where userId='$q_uid' ";
				$result=$db->query($sql);
				while($row=$result->fetch_assoc()){
					$q_user_info[$i]=$row;//将取得的所有数据赋值给person_info数组
				}
				if(isset($q_user_info[$i])) $ubuydetail[$i]['q_userName']=$q_user_info[$i]['userName'];
				else $ubuydetail[$i]['q_userName']="";

				//获取期数
				$sid=$ubuydetail[$i]['sid'];
				$sql="select s.qishu from `".$oto."_shoplist` as s where sid='{$sid}' order by qishu desc limit 1";
				$result=$db->query($sql);
				while($row=$result->fetch_assoc()){
					$qishu_info=$row;
				}
				if(isset($qishu_info)) $ubuydetail[$i]['max_qishu']=$qishu_info['qishu'];
				else $ubuydetail[$i]['max_qishu']="";
			}
		}
		if(isset($ubuydetail)) echo json_encode($ubuydetail);
		else echo '[]';

?>